package com.cwj.io.bio;

import java.io.*;
import java.net.Socket;

/**
 * @author: Chenwujie
 * @date: 2021-05-19 15:51
 */
public class ClientSocketTest {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 9232);

        BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        PrintWriter out = new PrintWriter(socket.getOutputStream(), true);

        BufferedReader sin = new BufferedReader(new InputStreamReader(System.in));
        String readline;
        readline = sin.readLine();

        while (!readline.equals("bye")) {
            out.print(readline);
            out.flush();
            System.out.println("me: " + readline);
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("server: " + in.readLine());
            readline = sin.readLine();
        }

    }
}
